package main

import (
	"fmt"
	"os"
)

func main() {
	file, err := os.Open("aa.txt")

	//file, err := os.OpenFile("aa.txt", os.O_RDWR, os.ModePerm)
	defer file.Close()
	if err != nil {
		fmt.Println(err)
	} else {
		fmt.Println(file)
	}
	bs := make([]byte, 4)
	n, _ := file.Read(bs)

	fmt.Println("读取了", n, "个字节")
	fmt.Println(string(bs))
	n1, _ := file.Read(bs)
	fmt.Println("读取了", n1, "个字节")
	fmt.Println(string(bs))
	n2, _ := file.Read(bs)
	fmt.Println("读取了", n2, "个字节")
	fmt.Println(string(bs))
	n3, _ := file.Read(bs)
	fmt.Println("读取了", n3, "个字节")
	fmt.Println(string(bs))
	n4, err := file.Read(bs)
	fmt.Println("读取了", n4, "个字节")
	fmt.Println(string(bs))
	fmt.Println("结束的标志", err)

}
